package com.scc.config;

import com.scc.interceptor.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置类注册拦截器
@Configuration
public class InterceptionConfig implements WebMvcConfigurer {
    //从ioc容器中拿出拦截器
    @Autowired
    private Interceptor interceptor;

    //重写方法（添加拦截器的方法）
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器.增加拦截路径.解除哪些路径
        registry.addInterceptor(interceptor).addPathPatterns("/**").excludePathPatterns("/admin/login");
    }

}
